home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / ctlmod / av_files.c next >
Encoding:
C/C++ Source or Header  |  1992-09-18  |  915 b   |  54 lines

  1. # include    <ingres.h>
  2. # include    <stdio.h>
  3. # include    <aux.h>
  4. # include    <opsys.h>
  5. # include    "ctlmod.h"
  6. # include    <sccs.h>
  7.  
  8. SCCSID(@(#)av_files.c    8.1    12/31/84)
  9.  
  10. /*
  11. **  AV_FILES -- return number of files available for user files.
  12. **
  13. **    Takes NOFILE and reduces it by the number of files that are
  14. **    open or could be open (for the catalog descriptors).
  15. **
  16. **    Parameters:
  17. **        none.
  18. **
  19. **    Returns:
  20. **        the number of available file descriptor to play with.
  21. **
  22. **    Side Effects:
  23. **        none.
  24. */
  25.  
  26. extern struct desxx    Desxx[];
  27.  
  28. av_files()
  29. {
  30.     auto long        fopn;
  31.     register int        nopn;
  32.     register int        i;
  33.     register struct desxx    *p;
  34.  
  35.     markopen(&fopn);
  36.     nopn = 0;
  37.     for (i = 0; i < 32; i++)
  38.     {
  39.         if (bitset(1 << i, fopn))
  40.             nopn++;
  41.     }
  42.  
  43.     /* now scan the descriptor cache */
  44.     for (p = Desxx; p->cach_relname != NULL; p++)
  45.     {
  46.         if (p->cach_alias != NULL)
  47.             continue;
  48.         if (p->cach_desc->relopn == 0)
  49.             nopn++;
  50.     }
  51.  
  52.     return (NOFILE - nopn);
  53. }
  54.